package interviewpreparationkit.dictionary

/**
 * [Hash Tables: Ransom Note](https://www.hackerrank.com/challenges/ctci-ransom-note)
 */
// Complete the checkMagazine function below.
fun checkMagazine(magazine: Array<String>, note: Array<String>): Unit {
    val magazineList = magazine.toMutableList()

    for (word in note) {
        val index = magazineList.indexOf(word)
        if (index < 0) {
            println("No")
            return
        } else {
            magazineList.removeAt(index)
        }
    }
    println("Yes")
}